package com.imooc.demo1;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author wangc
 */
public class SpringDemo1Test {
    @Test
    public void demo1() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService) applicationContext.getBean("userService");
        String s = userService.sayHello("小黑");
        System.out.println(s);
    }

//    @Test
////    public void demo2() {
////        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
////        UserService userService = (UserService) applicationContext.getBean("userService");
////        userService.eat();
////    }

    @Test
    public void demo3() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService) applicationContext.getBean("userService");
        userService.save();
    }
}
